﻿using AbpApplication.Expand;
using AbpApplication.InPut;
using AbpToDomain.EntityInfo;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace AbpApplication.AppServices
{
    public class CusetomService : ApplicationService, ICustomService
    {

        private readonly IRepository<TaskOrder> taskorder_res;
        private readonly IRepository<NeetOutMaterial> neetout_res;
        private readonly IRepository<MaterialBase> material_res;
        private readonly IRepository<NeetOutMaterial> neetoutmaterial_res;
        private readonly IRepository<CusetomOrder> cusetom_order_res;
        private readonly IRepository<CusetomOrderLine> cusetom_order_line_res;
        private readonly IRepository<MaterialProperty> MaterialProperty_res;
        private readonly ILoginHelper loginHelper;

        public CusetomService(IRepository<TaskOrder> taskorder_res,
            IRepository<NeetOutMaterial> neetout_res,
            IRepository<MaterialBase> material_res,
            IRepository<NeetOutMaterial> neetoutmaterial_res, ILoginHelper loginHelper,
            IRepository<CusetomOrder> cusetom_order_res,
            IRepository<CusetomOrderLine> cusetom_order_line_res, IRepository<MaterialProperty> materialProperty_res)

        {
            this.taskorder_res = taskorder_res;
            this.neetout_res = neetout_res;
            this.material_res = material_res;
            this.neetoutmaterial_res = neetoutmaterial_res;
            this.loginHelper = loginHelper;
            this.cusetom_order_res = cusetom_order_res;
            this.cusetom_order_line_res = cusetom_order_line_res;
            MaterialProperty_res = materialProperty_res;
        }

        public async Task<ApiResponse> CreateBinInfo()
        {
            return new ApiResponse("添加成功", true, null);
        }

        public async Task<ApiResponse> CreateMaterialProperty(CustomApiInPut InPut)
        {
            try
            {
                MaterialProperty materialProperty = new MaterialProperty();
                materialProperty.MaterialProertyname = InPut.MaterialProertyname;
                materialProperty.Description = InPut.Description;
                materialProperty.Unit = InPut.Unit;
                materialProperty.Type = InPut.Type;
                await MaterialProperty_res.InsertAsync(materialProperty);
                return new ApiResponse("添加成功", true, null);
            }
            catch (Exception ex)
            {
                loginHelper.LoginAsync(InPut, "CreateMaterialProperty");
                return new ApiResponse("内部错误服务器-CreateMaterialProperty", false, null);
            }
        }
    }
}
